package com.becca.cake.model.coupon;

import java.io.Serializable;
import java.util.Date;

import com.becca.cake.core.exception.ServiceException;
import com.becca.cake.util.StringUtil;

/**
 * 分享红包规则实体类
 * @copyright  尊星(上海)信息科技有限公司
 * @author yellow
 * @date 2016年6月7日 下午4:48:42
 */
public class PartookCouponRuleModel  implements Serializable{
    
    private static final long serialVersionUID = 1L;
    
    private Integer id;
    /**规则名称*/
    private String couponRuleName;
    /**规则类型( partake:分享者 receive:领取者)*/
    private String ruleType;
    /**规则有效天数*/    
    private Integer effectiveDay;
    /**是否随机金额(1:否 2：是)*/
    private Byte isRandomMoney;
    /**随机金额 例如：1-10*/
    private String moneyNumber;
    /**是否可用(1:可用 2:不可用)*/
    private Byte isEnable;
    /**创建时间*/
    private Date              createdDate;
    /**创建人*/
    private String            createdName;
    /**修改时间*/
    private Date              updatedDate;
    /**修改人*/
    private String            updatedName;
    
    /**是否可用(1:可用 )*/
    public static final Byte IS_ENALBE = 1;
    /**是否可用( 2:不可用 )*/
    public static final Byte IS_NOT_ENALBE = 2;
    /**规则名称不能为空*/
    public static final String COUPONRULENAME_NULL = "规则名称不能为空";
    /**规则类型不能为空*/
    public static final String RULETYPE_NULL = "规则类型不能为空";
    /**规则有效天数不能为空*/
    public static final String EFFECTIVEDAY_NULL = "规则有效天数不能为空";
    /**是否随机金额不能为空*/
    public static final String ISRANDOMMONEY_NULL = "是否随机金额不能为空";
    /**随机金额不能为空*/
    public static final String MONEYNUMBER_NULL = "随机金额不能为空";
    /**红包规则不能为空*/
    public static final String PARTOOK_COUPON_RULE_NULL = "红包规则不能为空";
    /**该红包规则已删除*/
    public static final String PARTOOK_COUPON_RULE_IS_DELETE = "该红包规则已删除";
    /**红包规则ID为空*/
    public static final String PARTOOK_COUPON_RULE_ID_NULL = "红包规则ID为空";
    
    
    /**
     * 校验是否为空
     */
    public static void validCouponRuleIsNull(PartookCouponRuleModel partookCouponRuleModel)throws ServiceException{
        if(partookCouponRuleModel == null ){
            throw new ServiceException(PartookCouponRuleModel.PARTOOK_COUPON_RULE_NULL);
        }
        if(StringUtil.isEmpty(partookCouponRuleModel.getCouponRuleName())){
            throw new ServiceException(PartookCouponRuleModel.COUPONRULENAME_NULL);
        }
        if(StringUtil.isEmpty(partookCouponRuleModel.getRuleType())){
            throw new ServiceException(PartookCouponRuleModel.RULETYPE_NULL);
        }
        if(StringUtil.isEmpty(partookCouponRuleModel.getMoneyNumber())){
            throw new ServiceException(PartookCouponRuleModel.MONEYNUMBER_NULL);
        }
        if(partookCouponRuleModel.getEffectiveDay() == null){
            throw new ServiceException(PartookCouponRuleModel.EFFECTIVEDAY_NULL);
        }
        if(StringUtil.isEmpty(partookCouponRuleModel.getIsRandomMoney().toString())){
            throw new ServiceException(PartookCouponRuleModel.ISRANDOMMONEY_NULL);
        }
    }
    
    /**
     * 校验红包规则ID是否为空
     * @param id
     */
    public static void validSelectCouponRuleById(Integer id){
        if(id == null){
            throw new ServiceException(PartookCouponRuleModel.PARTOOK_COUPON_RULE_ID_NULL);
        }
    }
    
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getCouponRuleName() {
        return couponRuleName;
    }
    public void setCouponRuleName(String couponRuleName) {
        this.couponRuleName = couponRuleName;
    }
    public String getRuleType() {
        return ruleType;
    }
    public void setRuleType(String ruleType) {
        this.ruleType = ruleType;
    }
    public Integer getEffectiveDay() {
        return effectiveDay;
    }
    public void setEffectiveDay(Integer effectiveDay) {
        this.effectiveDay = effectiveDay;
    }
    public Byte getIsRandomMoney() {
        return isRandomMoney;
    }
    public void setIsRandomMoney(Byte isRandomMoney) {
        this.isRandomMoney = isRandomMoney;
    }
    public String getMoneyNumber() {
        return moneyNumber;
    }
    public void setMoneyNumber(String moneyNumber) {
        this.moneyNumber = moneyNumber;
    }
    public Byte getIsEnable() {
        return isEnable;
    }
    public void setIsEnable(Byte isEnable) {
        this.isEnable = isEnable;
    }
    public Date getCreatedDate() {
        return createdDate;
    }
    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }
    public String getCreatedName() {
        return createdName;
    }
    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }
    public Date getUpdatedDate() {
        return updatedDate;
    }
    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }
    public String getUpdatedName() {
        return updatedName;
    }
    public void setUpdatedName(String updatedName) {
        this.updatedName = updatedName;
    }
}
